package com.flute.icrawler.framework.framework;

import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.List;

/**
 * url容器，包括了对url的存储，读取和处理动作
 * @author Administrator
 *
 */
/**
 * @author Administrator
 * 
 */
public interface ICrawlUrlPool extends Remote {

	/**
	 * @return 返回下一等待处理的链接
	 */
	public CrawlUrl nextUrl() throws RemoteException;

	/**
	 * @return 返回下一批等待处理的链接
	 */
	public List<CrawlUrl> nextUrl(int n) throws RemoteException;

	/**
	 * @return 是否还有链接没有被处理
	 */
	public boolean hasNext() throws RemoteException;

	public boolean isProcessing() throws RemoteException;

	/**
	 * 对url做失败的处理
	 * 
	 * @param url
	 *            url链接
	 */
	public void fail(CrawlUrl url) throws RemoteException;

	/**
	 * 对url做成功的处理
	 * 
	 * @param url
	 *            url链接
	 */
	public void success(CrawlUrl url) throws RemoteException;

	/**
	 * 对url做重试的处理
	 * 
	 * @param url
	 *            url链接
	 */
	public void retry(CrawlUrl url) throws RemoteException;

	/**
	 * 对url做被过滤的处理
	 * 
	 * @param url
	 *            url链接
	 */
	public void filter(CrawlUrl url) throws RemoteException;

	/**
	 * 加入新的url
	 * 
	 * @param url
	 * @throws RemoteException
	 */
	public void add(CrawlUrl url) throws RemoteException;

	public void addAll(List<CrawlUrl> crawlUrls) throws RemoteException;

	
	
	/**
	 * 判断容器是否包含url
	 * 
	 * @param url
	 * @return 包含返回true，否则返回false
	 */
	public boolean contains(String url) throws RemoteException;

	public CrawlJob getCrawlJob() throws RemoteException;

	/**
	 * 通知所有的观察者
	 * 
	 * @param url
	 * @throws RemoteException
	 */
	public void notityCrawlUrl(CrawlUrl url) throws RemoteException;

}
